package o;

import com.google.gson.JsonSyntaxException;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

final class asu extends ato<Date> {
    private final Class<? extends Date> ˋ;
    private final List<DateFormat> ॱ = new ArrayList();

    public /* synthetic */ void ˎ(aux o_aux, Object obj) throws IOException {
        ˏ(o_aux, (Date) obj);
    }

    public /* synthetic */ Object ˏ(auy o_auy) throws IOException {
        return ˋ(o_auy);
    }

    asu(Class<? extends Date> cls, String str) {
        this.ˋ = ˎ((Class) cls);
        this.ॱ.add(new SimpleDateFormat(str, Locale.US));
        if (!Locale.getDefault().equals(Locale.US)) {
            this.ॱ.add(new SimpleDateFormat(str));
        }
    }

    public asu(Class<? extends Date> cls, int i, int i2) {
        this.ˋ = ˎ((Class) cls);
        this.ॱ.add(DateFormat.getDateTimeInstance(i, i2, Locale.US));
        if (!Locale.getDefault().equals(Locale.US)) {
            this.ॱ.add(DateFormat.getDateTimeInstance(i, i2));
        }
        if (atx.ˋ()) {
            this.ॱ.add(aty.ॱ(i, i2));
        }
    }

    private static Class<? extends Date> ˎ(Class<? extends Date> cls) {
        if (cls == Date.class || cls == java.sql.Date.class || cls == Timestamp.class) {
            return cls;
        }
        throw new IllegalArgumentException("Date type must be one of " + Date.class + ", " + Timestamp.class + ", or " + java.sql.Date.class + " but was " + cls);
    }

    public void ˏ(aux o_aux, Date date) throws IOException {
        if (date == null) {
            o_aux.ᐝ();
            return;
        }
        synchronized (this.ॱ) {
            o_aux.ˊ(((DateFormat) this.ॱ.get(0)).format(date));
        }
    }

    public Date ˋ(auy o_auy) throws IOException {
        if (o_auy.ʻ() == auz.ʽ) {
            o_auy.ॱॱ();
            return null;
        }
        Date ˎ = ˎ(o_auy.ʽ());
        if (this.ˋ == Date.class) {
            return ˎ;
        }
        if (this.ˋ == Timestamp.class) {
            return new Timestamp(ˎ.getTime());
        }
        if (this.ˋ == java.sql.Date.class) {
            return new java.sql.Date(ˎ.getTime());
        }
        throw new AssertionError();
    }

    private Date ˎ(String str) {
        Date parse;
        synchronized (this.ॱ) {
            for (DateFormat parse2 : this.ॱ) {
                try {
                    parse = parse2.parse(str);
                    break;
                } catch (ParseException e) {
                }
            }
            try {
                parse = aus.ˋ(str, new ParsePosition(0));
            } catch (Throwable e2) {
                throw new JsonSyntaxException(str, e2);
            }
        }
        return parse;
    }

    public String toString() {
        DateFormat dateFormat = (DateFormat) this.ॱ.get(0);
        if (dateFormat instanceof SimpleDateFormat) {
            return "DefaultDateTypeAdapter(" + ((SimpleDateFormat) dateFormat).toPattern() + ')';
        }
        return "DefaultDateTypeAdapter(" + dateFormat.getClass().getSimpleName() + ')';
    }
}
